package avicit.cbb.elefileupdown.service.api;


import avicit.cbb.businessclass.system.dataauth.domain.CbbAuthResource;
import avicit.platform6.core.rest.msg.ResponseMsg;
import avicit.platform6.core.restclient.RestClient;
import avicit.platform6.core.restclient.RestClientUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class FileUploadIntfsServiceApi {



    /**
     * 服务编码
     */
    private static final String SERVICE_CODE = "filebasicmanager";

    private static final String BASE_PATH = "/api/avicit/cbb/elefileupdown/rest/FileUploadIntfsServiceRest";

    @Autowired
    private RestClient restClient;


    /**
     *通过数据id获取附件信息集合
     * @param dataId
     * @return
     */
    public List<Map<String, Object>> getAttachmentsByRecordId(String dataId) {
        String url = BASE_PATH + "/getAttachmentsByRecordId";
        Map<String,Object> map = new HashMap<>();
        map.put("dataId",dataId);
        ResponseMsg<List<Map<String, Object>>> responseMsg = restClient.doPost(SERVICE_CODE, url, map,  new ParameterizedTypeReference<ResponseMsg<List<Map<String, Object>>>>() {
        });
        return RestClientUtils.getResponseBody(responseMsg);
    }
}
